﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using proRFID_DiemDanh.Chung;

namespace proRFID_DiemDanh.Khoa
{
    public partial class SuaKhoa : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (string.IsNullOrEmpty(Request["ID"]))
                    Response.Redirect("../Khoa/Khoa.aspx");
                HienThi();
            }
        }

        protected void Imgcmd_SuaKhoa_Click(object sender, ImageClickEventArgs e)
        {
            DataTable dt = new DataTable();
            dt = mdKhoa.sp_Khoa_Update(Convert.ToInt32(Request["ID"]),txt_TenKhoa.Text.Trim());
            if (dt.Rows[0]["ErrCode"].ToString() == "0")
                mdMain.OKBox(this, dt.Rows[0]["ErrMsg"].ToString(), "/Khoa/Khoa.aspx");
            else
                mdMain.OKCancelBox(this, dt.Rows[0]["ErrMsg"].ToString() + ". Bạn có muốn thử lại không?", "/Khoa/Khoa.aspx");
        }

        void HienThi()
        {
            DataTable dt = new DataTable();
            dt = mdKhoa.sp_Khoa_Select(Convert.ToInt32(Request["ID"]));
            txt_TenKhoa.Text = dt.Rows[0]["TENKHOA"].ToString();
        }
    }
}